{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Demo 01: Describing your geometry"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To see a demo of what the geometry paramterers should look like, do as follows: "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "TIGRE parameters\n",
      "-----\n",
      "Geometry parameters\n",
      "Distance from source to detector (DSD) = 1536 mm\n",
      "Distance from source to origin (DSO)= 1000 mm\n",
      "-----\n",
      "Detector parameters\n",
      "Number of pixels (nDetector) = [128 128]\n",
      "Size of each pixel (dDetector) = [3.2 3.2] mm\n",
      "Total size of the detector (sDetector) = [409.6 409.6] mm\n",
      "-----\n",
      "Image parameters\n",
      "Number of voxels (nVoxel) = [64 64 64]\n",
      "Total size of the image (sVoxel) = [256 256 256] mm\n",
      "Size of each voxel (dVoxel) = [4. 4. 4.] mm\n",
      "-----\n",
      "Offset correction parameters\n",
      "Offset of image from origin (offOrigin) = [0 0 0] mm\n",
      "Offset of detector (offDetector) = [0 0] mm\n",
      "-----\n",
      "Auxillary parameters\n",
      "Samples per pixel of forward projection (accuracy) = 0.5\n",
      "-----\n",
      "Rotation of the Detector (rotDetector) = [0 0 0] rad\n"
     ]
    }
   ],
   "source": [
    "import tigre\n",
    "geo = tigre.geometry_default(high_quality = False)\n",
    "print(geo)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We recommend using the template below and defining you're class as such: \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from __future__ import division\n",
    "import numpy as np\n",
    "\n",
    "\n",
    "class Geometry:\n",
    "\n",
    "    def __init__(self, high_quality=True):\n",
    "        if high_quality:\n",
    "            # VARIABLE                                          DESCRIPTION                    UNITS\n",
    "            # -------------------------------------------------------------------------------------\n",
    "            self.DSD = 1536                                     # Distance Source Detector      (mm)\n",
    "            self.DSO = 1000                                     # Distance Source Origin        (mm)\n",
    "            # Detector parameters\n",
    "            self.nDetector = np.array((512, 512))               # number of pixels              (px)\n",
    "            self.dDetector = np.array((0.8, 0.8))               # size of each pixel            (mm)\n",
    "            self.sDetector = self.nDetector * self.dDetector    # total size of the detector    (mm)\n",
    "            # Image parameters\n",
    "            self.nVoxel = np.array((256, 256, 256))             # number of voxels              (vx)\n",
    "            self.sVoxel = np.array((256, 256, 256))             # total size of the image       (mm)\n",
    "            self.dVoxel = self.sVoxel/self.nVoxel               # size of each voxel            (mm)\n",
    "            # Offsets\n",
    "            self.offOrigin = np.array((0, 0, 0))                # Offset of image from origin   (mm)\n",
    "            self.offDetector = np.array((0, 0))                 # Offset of Detector            (mm)\n",
    "\n",
    "            # Auxiliary\n",
    "            self.accuracy = 0.5                                 # Accuracy of FWD proj          (vx/sample)\n",
    "            # Mode\n",
    "            self.mode = 'cone'                                  # parallel, cone                ...\n",
    "        else:\n",
    "            # VARIABLE                                          DESCRIPTION                    UNITS\n",
    "            # -------------------------------------------------------------------------------------\n",
    "            self.DSD = 1536                                     # Distance Source Detector      (mm)\n",
    "            self.DSO = 1000                                     # Distance Source Origin        (mm)\n",
    "            # Detector parameters\n",
    "            self.nDetector = np.array((128, 128))             # number of pixels              (px)\n",
    "            self.dDetector = np.array((0.8, 0.8))*4             # size of each pixel            (mm)\n",
    "            self.sDetector = self.nDetector * self.dDetector    # total size of the detector    (mm)\n",
    "            # Image parameters\n",
    "            self.nVoxel = np.array((64, 64 , 64))           # number of voxels              (vx)\n",
    "            self.sVoxel = np.array((256, 256, 256))             # total size of the image       (mm)\n",
    "            self.dVoxel = self.sVoxel / self.nVoxel             # size of each voxel            (mm)\n",
    "            # Offsets\n",
    "            self.offOrigin = np.array((0, 0, 0))                # Offset of image from origin   (mm)\n",
    "            self.offDetector = np.array((0, 0))                 # Offset of Detector            (mm)\n",
    "\n",
    "            # Auxiliary\n",
    "            self.accuracy = 0.5                                 # Accuracy of FWD proj          (vx/sample)\n",
    "            # Mode\n",
    "            self.mode=None                                      # parallel, cone                ...\n",
    "            self.filter=None"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.15+"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
